package com.itheima.controller.utils;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * className: ProjectExceptionAdvice
 * description: SpringMvc 的异常处理器
 * date: 2023/2/23 0023-PM 11:04:39
 * <p>
 * project: springboot
 * package: com.itheima.controller.utils
 * email: 1085844536@qq.com
 * version:
 *
 * @author WangGuojian
 */
// @ControllerAdvice
@RestControllerAdvice
public class ProjectExceptionAdvice {

    /**
     * 拦截所有的异常信息
     *
     * @param ex {@link Exception}
     */
    @ExceptionHandler(Exception.class)
    public R doException(Exception ex) {
        // 记录日志
        // 通知运维
        ex.printStackTrace();
        return new R("服务器故障，请稍后再试！");
    }
}
